package com.stu.boke.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.stu.boke.entity.Page;
import com.stu.boke.mapper.PageMapper;
import com.stu.boke.service.PageService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class PageServiceImpl implements PageService{

	@Autowired(required = false)
	private PageMapper pageMapper;


	@Override
	public List<Page> listPage() {
		List<Page> pageList = null;
        try {
            pageList = pageMapper.listPage(null);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("获得所有标签失败, cause:{}", e);
        }
        return pageList;
	}


	@Override
	public Page insertSubmitPage(Page page) {
		try {
			pageMapper.insert(page);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("创建分类失败, page:{}, cause:{}", page, e);
		}
		return page;
	}


	@Override
	public void updatePage(Page page) {
		try {
			pageMapper.update(page);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("更新分类失败, page:{}, cause:{}", page, e);
		}
	}

	@Override
	public void deletePage(Integer id) {
		try {
			pageMapper.deleteById(id);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("删除分类失败, page:{}, cause:{}",  e);
		}
	}


	@Override
	public Page getPageById(Integer id) {
		return pageMapper.getPageById(id);
	}


	@Override
    public Page getPageByKey(Integer status, String key) {
        return pageMapper.getPageByKey(status, key);
    }


}
